﻿Imports System.Collections.Generic
Public Class ThucDonDAO
    'phuong thuc lay danh sach dua vao ma mon

    Public Shared Function laydanhsachthucdon(ByVal tdon As String) As List(Of CThucDon)
        Dim kq As List(Of CThucDon) = New List(Of CThucDon)
        Dim str As String = String.Format("SELECT * from ThucDon where MaMon='{0}' ", tdon)
        Dim dt As DataTable = CKetNoi.ExecQuery(str)
        For Each i As DataRow In dt.Rows
            Dim td As New CThucDon
            td.MaMon = i("MaMon")
            td.TenMon = i("TenMon")
            td.MaLoai = i("MaLoai")
            td.DonGia = i("DonGia")
            td.DVT = i("DVT")
            kq.Add(td)
        Next
        Return kq
    End Function
    Public Shared Function Insert(ByVal b As CThucDon) As Integer
        Dim sql As String = String.Format("INSERT INTO ThucDon(MaMon,TenMon,MaLoai,DonGia,DVT) VALUES('{0}','{1}','{2}',{3},'{4}')", b.MaMon, b.TenMon, b.MaLoai, b.DonGia, b.DVT)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Delete(ByVal mmon As String) As Integer
        Dim sql As String = String.Format("Delete from ThucDon where MaMon='{0}'", mmon)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Update(ByVal b As CThucDon) As Integer
        Dim sql As String = String.Format("Update Phieu set TenMon='{0}',MaLoai='{1}',DonGia={2},DVT='{3}'", b.TenMon, b.MaLoai, b.DonGia, b.DVT)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
End Class
